package org.test.jiazi_1;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

@SpringBootApplication
public class ApiTest2Application {

    public static void main(String[] args) {
        // 只启动一次Spring应用并获取上下文对象
        ConfigurableApplicationContext context = SpringApplication.run(ApiTest2Application.class, args);

        // 从上下文对象中获取环境配置
        String contextPath = context.getEnvironment().getProperty("server.servlet.context-path");
        String port = context.getEnvironment().getProperty("server.port");
        // 打印接口文档地址
        System.out.println("http://127.0.0.1:%s%s/doc.html".formatted(port, contextPath));
    }

}
